export default {
    data() {
        return {
            rightStyle : {},
        }
    },
    mounted() {
        setTimeout(() => {
            this.scrollRightTop();
        }, 200);
        window.addEventListener('scroll', this.scrollRightTop);
    },
    beforeDestroy() {
        window.removeEventListener('scroll', this.scrollRightTop);
    },
    methods: {
        /**计算滚动距离 右边滚动到顶部停止滚动*/
        scrollRightTop() {
            const contentRightDom = document.querySelector('.content-right');
            if(!contentRightDom) return;
            let contentRightDomLeft = contentRightDom.getBoundingClientRect().left;
            // 获取屏幕高度
            let screenHeight = document.querySelector(".public-header") ? document.querySelector(".public-header").clientHeight :  window.innerHeight;
            if(window.scrollY - 240 > screenHeight){
                this.rightStyle = {
                    position : 'fixed',
                    top : '-200px',
                    left : contentRightDomLeft + 'px',
                    width: contentRightDom.offsetWidth + 'px',
                }
            }else{
                this.rightStyle = {};
            }
        },
    }
}